<h2>DESCRIPTION</h2>

<em>v.category</em> attaches, copies, deletes or reports categories to/from/of 
vector geometry objects. Further on, <em>v.category</em> adds a number 
given by the <em>cat</em> option to categories of the selected layer. 
These categories (IDs) are used to assign IDs or to group geometry objects
into categories (several different geometry objects share the same 
category). These categories are also used to link geometry
object(s) to attribute records (from an attribute table linked to vector map).


<h2>NOTES</h2>

Use <em><a href="v.to.db.html">v.to.db</a></em> to upload related categories
to a linked attribute table.

<p>The <b>type</b> parameter specifies the type of geometry objects to which
the category is added; it is similar to an input filter - only the
geometry specified in 'type' is processed.

<p>If the <b>type</b> parameter is set to <b>centroid</b> and
the <b>option</b> parameter set to <b>add</b>, new categories will be
added to existing centroids. Note however, that new centroids cannot
be created this way.  To do so, they must be added manually
using <em><a href="wxGUI.vdigit.html">wxGUI vector
digitizer</a></em> or by running <em>v.category</em> with the type
parameter set to area.

<p>If categories are copied with <em>option=transfer</em>, a warning is 
issued if categories already exit in the layer they are copied to. In 
this case the user must make sure beforehand that copying categories 
from one layer to another layer does not cause undesired grouping of 
different geometry objects into the same categories. This can be avoided 
by specifying only one <em>layer</em>. The module will then find the 
next free layer number and copy categories to there. The new layer number 
is reported at the end.
    
<p>Areas are a special case because it is impossible to attach a cat to
an area without a centroid; in this case, the module places new
centroids in areas automatically for <b>type=area</b>.

<p>The <b>cat</b> parameter is only used with <b>option</b>=<i>add</i>, 
<b>option</b>=<i>sum</i> and <b>option</b>=<i>del</i>.

<p>Categories can be deleted for the given layer with <em>option=del</em>. 
If <b>cat</b> is set to <i>-1</i>, all categories for the given layer 
are deleted. If <b>cat</b> is zero or positive, only this category value 
will be deleted. By default, <b>cat</b> is set to <i>1</i> which means 
that only categories of value <i>1</i> will be deleted. 

<p>With <b>option=report</b>, the module reports for each layer and 
type the total number of categories, the minimum and the maximum 
category number. If there are e.g. two lines with line 1 having 
category 1 and line 1 having categories 1 and 2, then there are a total 
of three category values with minimum 1 and maximum 2.  

<p>The <b>ids</b> parameter specifies the list of feature IDs to which the
operation is performed; by default, all vector feature ids are processed. 
The <i>feature ID</i> is an internal (unique) geometry ID that all vector
primitives possess, and is separate from any category the feature may
also possess. 
Use <div class="code"><pre>
  <em><a href="v.edit.html">v.edit</a></em> map=inputname tool=select
</pre></div>
to find out the geometry ids of certain features.


<h2>EXAMPLES</h2>

<h3>Report vector categories</h3>

<div class="code"><pre>
v.category input=testmap option=report

LAYER/TABLE 1/testmap:
type       count        min        max
point          0          0          0
line        1379          1       1379
boundary       0          0          0
centroid       0          0          0
area           0          0          0
all         1379          1       1379
</pre></div>

<h3>Delete all vector categories in layer 1</h3>

<div class="code"><pre>
v.category input=testmap output=outmap option=del cat=-1
</pre></div>

<h3>Add vector categories in layer 1 with step=2</h3>

<div class="code"><pre>
v.category input=outmap output=stepmap option=add step=2

# report
v.category input=stepmap option=report
LAYER/TABLE 1/outmap:
type       count        min        max
point          0          0          0
line        1379          1       2757
boundary       0          0          0
centroid       0          0          0
area           0          0          0
all         1379          1       2757
</pre></div>

<h3>Add categories/centroids to a vector map without categories</h3>

<div class="code"><pre>
v.category input=wkt output=wktnew option=add
</pre></div>

Results can be tested
using <em><a href="d.what.vect.html">d.what.vect</a></em>.

<h3>Copy categories from layer 1 to layer 2,3,4,5,6,7 and 8</h3>
Existing layer will be overwritten, non-existing will be created.
<div class="code"><pre>
v.category input=observer output=observer_new option=transfer layer=1,2,3,4,5,6,7,8
</pre></div>

<h3>Print vector categories of given layer</h3>

Print vector categories from the first layer, only for feature ids 1-50.

<div class="code"><pre>
v.category input=roads option=print layer=1 id=1-50
</pre></div>


<h2>SEE ALSO</h2>

<em>
<a href="v.centroids.html">v.centroids</a>,
<a href="v.db.connect.html">v.db.connect</a>,
<a href="v.edit.html">v.edit</a>,
<a href="v.to.db.html">v.to.db</a>
</em>


<h2>AUTHOR</h2>

Radim Blazek, ITC-irst, Trento, Italy<br>
Modified (the id parameter) by Martin Landa,
  FBK-irst (formerly ITC-irst), Trento, Italy, 2008/02

<!--
<p>
<i>Last changed: $Date$</i>
-->
